<?php
  /**
   * @author EVANDRO DE OLIVEIRA.
   * @category MODEL
   * @package MODELS.
   * @since 05/05/2012.
   * @last_update 05/05/2012.
   * @copyright 2012.
   * @version 1.0.
   *
   */
  class Application_Model_Logradouros extends Zend_Db_Table_Abstract{
    const IND_ATIVO = 1;
    const IND_INATIVO = 0;
    
    /**
     * Define a tabela padrão da controller
     */
    protected function _setup(){
      $this->_name = 'logradouros';
      parent::_setup();
    } 
    
    /**
     * Retorna todos os registros ativos.
     */
    public function getAtivos(){
      $strSql = $this->select()->where($this->_name . '.st_lograduro = ?', self::IND_ATIVO);
      
      $objResult = $this->fetchAll($strSql);
            
      return Core_Commons::onLoad($objResult);
    }
    
    public function getByCep($intCep){
    	$strSql = $this->select()->where($this->_name . '.ds_cep = ?', $intCep)->where($this->_name . '.st_lograduro = ?', self::IND_ATIVO);
      
      $objResult = $this->fetchRow($strSql);
            
      return Core_Commons::onLoad($objResult);
    }
  }